package com.example.mybatisplus;

import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@EnableFeignClients         //开启 Spring Cloud Feign 的支持功能
@EnableDiscoveryClient         //让注册中心能够发现
@SpringBootApplication
@EnableTransactionManagement    //开启事务管理
@MapperScan(basePackages = {"com.example.mybatisplus.mapper"})
@ComponentScan(basePackages = {"com.example"})
public class MybatisPlusApplication {

    private static final Logger logger = LoggerFactory.getLogger(MybatisPlusApplication.class);

    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(MybatisPlusApplication.class, args);
        ConfigurableEnvironment environment = context.getEnvironment();
        String url = "http://localhost:" + environment.getProperty("server.port") + environment.getProperty("server.servlet.context-path");

        logger.info("======启动完毕======");
        logger.info("接口访问地址" + url);
    }

}
